import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getx_learn/app/common/widgets/widgets.dart';
import 'package:getx_learn/app/routes/app_pages.dart';

import '../controllers/get_lazy_put_page1_controller.dart';

class GetLazyPutPage1View extends GetView<GetLazyPutPage1Controller> {
  const GetLazyPutPage1View({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(context: context, title: "Get.lazyPut"),
      body: Center(
        child: Column(
          children: [
            GetX<GetLazyPutPage1Controller>(
              init: Get.find<GetLazyPutPage1Controller>(),
              initState: (_) {},
              builder: (_) {
                return Text('value -> ${_.count}');
              },
            ),
            Divider(),

            // 按钮
            ElevatedButton(
              onPressed: () {
                Get.find<GetLazyPutPage1Controller>().increment();
              },
              child: Text('add'),
            ),

            // 跳转
            ElevatedButton(
              onPressed: () {
                Get.toNamed(Routes.GET_LAZY_PUT_PAGE2);
              },
              child: Text('Next GetView Page'),
            ),
          ],
        ),
      ),
    );
  }
}
